﻿using Newtonsoft.Json;
using System.Web.Http;

namespace FormsAuthWeb
{
    public class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API 路由
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            // 本地时区,没有了8小时的问题
            config.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
            // 设置日期格式，默认值是“yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK”所以返回的时间字符串中含T
            config.Formatters.JsonFormatter.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
        }
    }
}